package acm.蓝桥16;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.PriorityQueue;
import java.util.Scanner;

public class A凑出卡牌 {
    /**
     * 思路：贪心，每次给最小的加
     */
    public static void main(String[] args) {
        Reader sc = new Reader();
        int n = sc.nextInt();
        long m = sc.nextLong();
        long[][] card = new long[n][2];
        PriorityQueue<long[]> queue = new PriorityQueue<>((o1, o2) -> o1[0] < o2[0] ? -1 : 1);   //0位置卡牌数量，1位置卡牌次数
        for (int i = 0; i < card.length; i++) {
            card[i][0] = sc.nextInt();
        }
        for (int i = 0; i < card.length; i++) {
            card[i][1] = sc.nextInt();
        }
        for (long[] ints : card) {
            queue.add(ints);
        }
        for (long i = 0; i < m && !queue.isEmpty(); i++) {
            long[] poll = queue.poll();
            if (poll[1] <= 0) {
                queue.add(poll);
                break;
            }
            poll[0]++;
            poll[1]--;
            queue.add(poll);
        }
        System.out.println(queue.peek()[0]);
    }
    static class Reader {
        static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public static int nextInt() {
            try {
                in.nextToken();
            } catch (Exception ignored) {}
            return (int) in.nval;
        }
        public static long nextLong(){
            try {
                in.nextToken();
            } catch (Exception ignored) {}
            return (long) in.nval;
        }
    }
}
